#include <bits/stdc++.h>
using namespace std;
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
using ll = long long;
void solve()
{
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    ll hh = 0;
    for (ll i = 0; i < n; i++)
    {
        if ((x | i) == x)
        {
            //cout << hh << " ";
            hh |= i;
            a[i] = i;
        }
    }
    //cout << endl;
    if (hh != x)
    {
        a[n - 1] = x;
    }

    for (int i = 0; i < n; i++)
    {
        cout << a[i] << " ";
    }
    cout << endl;
}
int main()
{
    int t = 1;
     cin >> t;
    while (t--)
    {
        
         solve();
    }
    return 0;
}
